#include "stdafx.h"
#include <serialization/ioParamStructs.h>
#include <serialization/serialization.h>
#include <winsock/winsock_stub.h>

void socket_stub (
    __in  std::vector<char>& in_buf,
    __out std::vector<char>& out_buf
    )
{
//RECEIVE()
    Deserialize deserialize (in_buf);
    socket_in_inout socketIN;
    deserialize (socketIN);

    int ret = socket (socketIN.af_, socketIN.type_, socketIN.protocol_);
//SEND
    socket_out_inout socketOUT( ret, WSAGetLastError() );
    
    Serialize(deserialize.get_header(), socketOUT, out_buf);
}

void WSASocket_stub (
    __in  std::vector<char>& in_buf,
    __out std::vector<char>& out_buf
    )
{
//RECEIVE
    Deserialize deserialize (in_buf);
    WSASocket_in_inout WSASocketIN;
    deserialize (WSASocketIN);

    SOCKET ret = WSASocket (WSASocketIN.af_,
                            WSASocketIN.type_,
                            WSASocketIN.protocol_,
                            WSASocketIN.lpProtocolInfo_,
                            WSASocketIN.g_,
                            WSASocketIN.dwFlags_);
//SEND
    WSASocket_out_inout WSASocketOUT( ret, WSAGetLastError() );
    
    Serialize(deserialize.get_header(), WSASocketOUT, out_buf);
}
